package Servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class servletListaCotizaciones
 */
@WebServlet("/servletListaCotizaciones")
public class servletListaCotizaciones extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public servletListaCotizaciones() {
        super();
        
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String criterio = request.getParameter("sorting[0][order]");
		String cadena = "";
		
		System.out.println(criterio);
		response.setContentType("application/json");  // Set content type of the r	esponse so that jQuery knows what it can expect.
		response.setCharacterEncoding("UTF-8"); // You want world domination, huh?
		if(criterio.equals("ascending")){
			cadena = "{\"total_rows\":\"200\",\"page_data\":[{\"customer_id\":\"101\",\"lastname\":\"<a href=\\\"aprobar.jsp\\\" rel=\\\"nofollow\\\">Ascendente<\\/a>\",\"firstname\":\"Quemby\",\"email\":\"Fusce@Integer.edu\",\"gender\":\"female\",\"date_updated\":\"09\\/07\\/2006 00:09:31\"},{\"customer_id\":\"102\",\"lastname\":\"<a href=\\\"\\/test\\/102\\\" rel=\\\"nofollow\\\">Holland<\\/a>\",\"firstname\":\"Kessie\",\"email\":\"semper.tellus.id@egestasDuisac.edu\",\"gender\":\"hombre\",\"date_updated\":\"30\\/03\\/1997 11:35:34\"},{\"customer_id\":\"103\",\"lastname\":\"<a href=\\\"\\/test\\/103\\\" rel=\\\"nofollow\\\">Prince<\\/a>\",\"firstname\":\"Kylan\",\"email\":\"molestie.arcu@eu.edu\",\"gender\":\"female\",\"date_updated\":\"03\\/11\\/1998 22:58:24\"},{\"customer_id\":\"104\",\"lastname\":\"<a href=\\\"\\/test\\/104\\\" rel=\\\"nofollow\\\">Mayer<\\/a>\",\"firstname\":\"Zephr\",\"email\":\"sit@malesuadafamesac.org\",\"gender\":\"female\",\"date_updated\":\"27\\/12\\/2007 15:00:30\"},{\"customer_id\":\"105\",\"lastname\":\"<a href=\\\"\\/test\\/105\\\" rel=\\\"nofollow\\\">Mclean<\\/a>\",\"firstname\":\"Tanya\",\"email\":\"justo.Proin.non@acfeugiatnon.com\",\"gender\":\"female\",\"date_updated\":\"20\\/07\\/1999 05:11:24\"},{\"customer_id\":\"106\",\"lastname\":\"<a href=\\\"\\/test\\/106\\\" rel=\\\"nofollow\\\">Huff<\\/a>\",\"firstname\":\"Aimee\",\"email\":\"velit@Proin.org\",\"gender\":\"female\",\"date_updated\":\"25\\/04\\/1995 11:16:00\"},{\"customer_id\":\"107\",\"lastname\":\"<a href=\\\"\\/test\\/107\\\" rel=\\\"nofollow\\\">Moreno<\\/a>\",\"firstname\":\"Bethany\",\"email\":\"Suspendisse.ac@Duiscursusdiam.edu\",\"gender\":\"female\",\"date_updated\":\"19\\/01\\/1993 03:04:19\"},{\"customer_id\":\"108\",\"lastname\":\"<a href=\\\"\\/test\\/108\\\" rel=\\\"nofollow\\\">Mcmillan<\\/a>\",\"firstname\":\"Deanna\",\"email\":null,\"gender\":\"female\",\"date_updated\":\"27\\/12\\/2003 16:13:15\"},{\"customer_id\":\"109\",\"lastname\":\"<a href=\\\"\\/test\\/109\\\" rel=\\\"nofollow\\\">Mckee<\\/a>\",\"firstname\":\"Raya\",\"email\":\"amet@magnaetipsum.ca\",\"gender\":\"female\",\"date_updated\":\"05\\/11\\/2001 07:53:42\"},{\"customer_id\":\"110\",\"lastname\":\"<a href=\\\"\\/test\\/110\\\" rel=\\\"nofollow\\\">Mayo<\\/a>\",\"firstname\":\"Willow\",\"email\":\"nunc.sit@Integer.ca\",\"gender\":\"female\",\"date_updated\":\"24\\/11\\/2007 09:02:19\"}],\"error\":null,\"filter_error\":[],\"debug_message\":[]}";
	       
        
        } 
		else if(criterio.equals("descending"))
		{
			cadena = "{\"total_rows\":\"200\",\"page_data\":[{\"customer_id\":\"101\",\"lastname\":\"<a href=\\\"\\/test\\/101\\\" rel=\\\"nofollow\\\">Miguel<\\/a>\",\"firstname\":\"Quemby\",\"email\":\"Fusce@Integer.edu\",\"gender\":\"Hombre\",\"date_updated\":\"09\\/07\\/2006 00:09:31\"},{\"customer_id\":\"102\",\"lastname\":\"<a href=\\\"\\/test\\/102\\\" rel=\\\"nofollow\\\">Holland<\\/a>\",\"firstname\":\"Kessie\",\"email\":\"semper.tellus.id@egestasDuisac.edu\",\"gender\":\"hombre\",\"date_updated\":\"30\\/03\\/1997 11:35:34\"},{\"customer_id\":\"103\",\"lastname\":\"<a href=\\\"\\/test\\/103\\\" rel=\\\"nofollow\\\">Prince<\\/a>\",\"firstname\":\"Kylan\",\"email\":\"molestie.arcu@eu.edu\",\"gender\":\"female\",\"date_updated\":\"03\\/11\\/1998 22:58:24\"},{\"customer_id\":\"104\",\"lastname\":\"<a href=\\\"\\/test\\/104\\\" rel=\\\"nofollow\\\">Mayer<\\/a>\",\"firstname\":\"Zephr\",\"email\":\"sit@malesuadafamesac.org\",\"gender\":\"female\",\"date_updated\":\"27\\/12\\/2007 15:00:30\"},{\"customer_id\":\"105\",\"lastname\":\"<a href=\\\"\\/test\\/105\\\" rel=\\\"nofollow\\\">Mclean<\\/a>\",\"firstname\":\"Tanya\",\"email\":\"justo.Proin.non@acfeugiatnon.com\",\"gender\":\"female\",\"date_updated\":\"20\\/07\\/1999 05:11:24\"},{\"customer_id\":\"106\",\"lastname\":\"<a href=\\\"\\/test\\/106\\\" rel=\\\"nofollow\\\">Huff<\\/a>\",\"firstname\":\"Aimee\",\"email\":\"velit@Proin.org\",\"gender\":\"female\",\"date_updated\":\"25\\/04\\/1995 11:16:00\"},{\"customer_id\":\"107\",\"lastname\":\"<a href=\\\"\\/test\\/107\\\" rel=\\\"nofollow\\\">Moreno<\\/a>\",\"firstname\":\"Bethany\",\"email\":\"Suspendisse.ac@Duiscursusdiam.edu\",\"gender\":\"female\",\"date_updated\":\"19\\/01\\/1993 03:04:19\"},{\"customer_id\":\"108\",\"lastname\":\"<a href=\\\"\\/test\\/108\\\" rel=\\\"nofollow\\\">Mcmillan<\\/a>\",\"firstname\":\"Deanna\",\"email\":null,\"gender\":\"female\",\"date_updated\":\"27\\/12\\/2003 16:13:15\"},{\"customer_id\":\"109\",\"lastname\":\"<a href=\\\"\\/test\\/109\\\" rel=\\\"nofollow\\\">Mckee<\\/a>\",\"firstname\":\"Raya\",\"email\":\"amet@magnaetipsum.ca\",\"gender\":\"female\",\"date_updated\":\"05\\/11\\/2001 07:53:42\"},{\"customer_id\":\"110\",\"lastname\":\"<a href=\\\"\\/test\\/110\\\" rel=\\\"nofollow\\\">Mayo<\\/a>\",\"firstname\":\"Willow\",\"email\":\"nunc.sit@Integer.ca\",\"gender\":\"female\",\"date_updated\":\"24\\/11\\/2007 09:02:19\"}],\"error\":null,\"filter_error\":[],\"debug_message\":[]}";
	        
		}
		
		else
		{
			cadena = "{\"total_rows\":\"200\",\"page_data\":[{\"customer_id\":\"101\",\"lastname\":\"<a href=\\\"\\/test\\/101\\\" rel=\\\"nofollow\\\">nada<\\/a>\",\"firstname\":\"Quemby\",\"email\":\"Fusce@Integer.edu\",\"gender\":\"Hombre\",\"date_updated\":\"09\\/07\\/2006 00:09:31\"},{\"customer_id\":\"102\",\"lastname\":\"<a href=\\\"\\/test\\/102\\\" rel=\\\"nofollow\\\">Holland<\\/a>\",\"firstname\":\"Kessie\",\"email\":\"semper.tellus.id@egestasDuisac.edu\",\"gender\":\"hombre\",\"date_updated\":\"30\\/03\\/1997 11:35:34\"},{\"customer_id\":\"103\",\"lastname\":\"<a href=\\\"\\/test\\/103\\\" rel=\\\"nofollow\\\">Prince<\\/a>\",\"firstname\":\"Kylan\",\"email\":\"molestie.arcu@eu.edu\",\"gender\":\"female\",\"date_updated\":\"03\\/11\\/1998 22:58:24\"},{\"customer_id\":\"104\",\"lastname\":\"<a href=\\\"\\/test\\/104\\\" rel=\\\"nofollow\\\">Mayer<\\/a>\",\"firstname\":\"Zephr\",\"email\":\"sit@malesuadafamesac.org\",\"gender\":\"female\",\"date_updated\":\"27\\/12\\/2007 15:00:30\"},{\"customer_id\":\"105\",\"lastname\":\"<a href=\\\"\\/test\\/105\\\" rel=\\\"nofollow\\\">Mclean<\\/a>\",\"firstname\":\"Tanya\",\"email\":\"justo.Proin.non@acfeugiatnon.com\",\"gender\":\"female\",\"date_updated\":\"20\\/07\\/1999 05:11:24\"},{\"customer_id\":\"106\",\"lastname\":\"<a href=\\\"\\/test\\/106\\\" rel=\\\"nofollow\\\">Huff<\\/a>\",\"firstname\":\"Aimee\",\"email\":\"velit@Proin.org\",\"gender\":\"female\",\"date_updated\":\"25\\/04\\/1995 11:16:00\"},{\"customer_id\":\"107\",\"lastname\":\"<a href=\\\"\\/test\\/107\\\" rel=\\\"nofollow\\\">Moreno<\\/a>\",\"firstname\":\"Bethany\",\"email\":\"Suspendisse.ac@Duiscursusdiam.edu\",\"gender\":\"female\",\"date_updated\":\"19\\/01\\/1993 03:04:19\"},{\"customer_id\":\"108\",\"lastname\":\"<a href=\\\"\\/test\\/108\\\" rel=\\\"nofollow\\\">Mcmillan<\\/a>\",\"firstname\":\"Deanna\",\"email\":null,\"gender\":\"female\",\"date_updated\":\"27\\/12\\/2003 16:13:15\"},{\"customer_id\":\"109\",\"lastname\":\"<a href=\\\"\\/test\\/109\\\" rel=\\\"nofollow\\\">Mckee<\\/a>\",\"firstname\":\"Raya\",\"email\":\"amet@magnaetipsum.ca\",\"gender\":\"female\",\"date_updated\":\"05\\/11\\/2001 07:53:42\"},{\"customer_id\":\"110\",\"lastname\":\"<a href=\\\"\\/test\\/110\\\" rel=\\\"nofollow\\\">Mayo<\\/a>\",\"firstname\":\"Willow\",\"email\":\"nunc.sit@Integer.ca\",\"gender\":\"female\",\"date_updated\":\"24\\/11\\/2007 09:02:19\"}],\"error\":null,\"filter_error\":[],\"debug_message\":[]}";
	        
		}
		
		 response.getWriter().write(cadena);
	}

}
